<?php
/* @var $this TicketController */
/* @var $ticket Ticket */
/* @var $form CActiveForm */
?>
<div class="form">
	<div class="section">
		<div class="block">
			<?php
			$form = $this->beginWidget('CActiveForm', array(
				'id' => 'ticket-create-form',
				'enableAjaxValidation' => false,
					));
			?>
			<table class="form-table">
				<tr>
					<th scope="row" width="100"><?php echo $form->labelEx($ticket, 'name'); ?></th>
					<td>
						<?php if (isset(Yii::app()->session['email'])) {
							$tmp = Ticket::model()->findByAttributes(array('email' => Yii::app()->session['email']));
							$ticket->name = $tmp->name;
						} ?>
						<?php echo $form->textField($ticket, 'name', array('size' => 30)); ?>
						<?php echo $form->error($ticket, 'name'); ?>
					</td>
				</tr>
				<tr>
					<th scope="row" width="100"><?php echo $form->labelEx($ticket, 'email'); ?></th>
					<td>
						<?php if (isset(Yii::app()->session['email'])) $ticket->email= Yii::app()->session['email']; ?>
						<?php echo $form->textField($ticket, 'email', array('size' => 30)); ?>
						<?php echo $form->error($ticket, 'email'); ?>
					</td>
				</tr>
				<tr>
					<th scope="row" width="100"><?php echo $form->labelEx($ticket, 'mobile'); ?></th>
					<td>
						<?php echo $form->textField($ticket, 'mobile', array('size' => 30)); ?>
						<?php echo $form->error($ticket, 'mobile'); ?>
					</td>
				</tr>
				<tr>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<th scope="row" width="100"><?php echo $form->labelEx($ticket, 'ticket_type_id'); ?></th>
					<td>
						<?php echo $form->dropDownList($ticket, 'ticket_type_id', CHtml::listData(TicketType::model()->findAllByAttributes(array('agency_id' => $agency_id)), 'id', 'name'), array('prompt' => 'Select Type')); ?>
						<?php echo $form->error($ticket, 'ticket_type_id'); ?>
					</td>
				</tr>
				<!--<tr class="ticket-reference" style="<?php //echo (in_array($ticket->type, array('Agent', 'Transaction')) ? "" : "display: none;"); ?>">
					<th scope="row" width="100">
						<?php //echo $form->labelEx($ticket, 'reference'); ?>
					</th>
					<td>
						<?php //echo $form->textField($ticket, 'reference', array('size' => '60')); ?>
						<?php// echo $form->error($ticket, 'reference'); ?>
					</td>
				</tr> -->
				<tr>
					<th scope="row">
						<?php echo $form->labelEx($ticket, 'subject'); ?></th>
					<td>
						<?php echo $form->textField($ticket, 'subject', array('size' => 60)); ?>
						<?php echo $form->error($ticket, 'subject'); ?>
					</td>
				</tr>
				<tr>
					<th scope="row">
					<?php echo $form->labelEx($ticket,'summary'); ?></th>
					<td>
					
						<div class="ckeditor megin">
							<?php $this->widget('common.components.ckeditor.CKEditor', array(
								'model'=>$ticket,
								'attribute'=>'summary',
								'language'=>'en',
								'editorTemplate'=>'advanced',
								'width'	=>	'300px',
								'height'	=>	'420px',
								'options'=>array(
									//'filebrowserUploadUrl'=>$this->createUrl('upload'),
								),
								//'rows'=>10, 
								//'cols'=>30,
								'toolbar'=>array(
									array('Bold', 'Italic', 'Underline', 'Strike'),
									array('JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'),
									array('Format'),
									array( 'Font', 'FontSize', 'FontColor', 'TextColor'),
									'/',
									array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord' ),
									array('Image', 'Table', 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'),
									array('Subscript','Superscript'),
									array( 'Link', 'Unlink' ),
									//array('Source'),
								)
								)); 
							?>
						</div>
					</td>
				</tr>
				<tr>
					<th scope="row">
					Attach file
					</th>
					<td>
						<?php
							$this->widget('common.widgets.PsPlUpload.PsPlUploadWidget', array(
								'url' => array('/tickets/form/attach'),
								'max_file_size' => '50mb',
								'browseButtonText' => '<img src="/images/icons/fugue/magnifier.png" />Select Files...',
								'browseButtonOptions' => array(
									'id' => 'btnAttachBrowse',
									'class' => 'link-button with-icon',
									'style' => 'margin: 10px 0 0 0'
								),
								'filters' => array(
									array(
										"title" => "Image files",
										"extensions" => "jpg,jpeg,gif,png,bmp,tiff"
									),
									array(
										"title" => "Document Files",
										"extensions" => "pdf,doc,docx,xls,xlsx,txt,csv"
									),
								),
								'htmlOptions' => array(
									'class' => 'align-center'
								),
								'uploadButtonText' => true, // do not display
								'onPostInit' => 'onAttachPostInit',
								'onFilesAdded' => 'onAttachFileAdded',
								'onUploadProgress' => 'onAttachUploadProgress',
								'onUploadComplete' => 'onAttachUploadComplete'
							));
						?>
					</td>
				</tr>
			</table>
			<div class="row buttons">
				<?php if ($ticket->isNewRecord): ?>
					<?php echo CHtml::submitButton('Submit Ticket', array('class' => 'green')); ?>
				<?php else: ?>
					<?php echo CHtml::submitButton('Update Ticket', array('class' => 'green')); ?>
				<?php endif; ?>

			</div>
			<?php $this->endWidget(); ?>
		</div>
	</div>
</div><!-- form -->